package cn.wenlihelp.service.impl;

import cn.wenlihelp.bean.Article;
import cn.wenlihelp.mapper.ArticleMapper;
import cn.wenlihelp.service.ArticleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleMapper articleMapper;
    @Override
    public PageInfo<Article> findAll(int page,int pageSize,Article article) {
        PageHelper.startPage(page,pageSize);
        List<Article> articles = articleMapper.findAll(article);
        //articles.forEach(System.out::println);
        return new PageInfo<>(articles);
    }

    @Override
    public int add(Article article) {
        int a = articleMapper.insert(article);
        if(a==1){
            System.out.println("insert：成功"+a);
        }
        return a;
    }
}
